package com.xiao.service;

import com.github.pagehelper.PageHelper;
import com.xiao.dao.BookMapper;
import com.xiao.pojo.Appointment;
import com.xiao.pojo.Books;
import com.xiao.pojo.Borrow;


import java.util.List;

public class BookServiceImpl implements BookService{
    //service调dao层：组合dao
    private BookMapper bookMapper;

    public void setBookMapper(BookMapper bookMapper) {
        this.bookMapper = bookMapper;
    }

    public int addBook(Books books) {
        return bookMapper.addBook(books);
    }

    public int deleteBookById(int id) {
        return bookMapper.deleteBookById(id);
    }

    public int updateBook(Books books) {
        return bookMapper.updateBook(books);
    }

    public Books queryBookById(int id) {
        return bookMapper.queryBookById(id);
    }



    public List<Books> queryAllBook(int page,int size) {
        PageHelper.startPage(page,size);


        return bookMapper.queryAllBook();
    }

    public Books queryBookByName(String bookName) {
        return bookMapper.queryBookByName(bookName);
    }

    public int addBorrow(Borrow borrow) {
        return bookMapper.addBorrow(borrow);
    }

    public List<Borrow> queryAllBorrow() {
        return bookMapper.queryAllBorrow();
    }


    public List<Borrow> queryAllBorrowBySno(String sno) {
        return  bookMapper.queryAllBorrowBySno(sno);
    }

    public int returnBook(int bookID) {
        return  bookMapper.returnBook(bookID);
    }

    public int reduceBook(int bookID) {
        return bookMapper.reduceBook(bookID);
    }

    public int increaseBook(int bookID) {
        return bookMapper.increaseBook(bookID);
    }

    public int addAppoint(Appointment appointment) {
        return bookMapper.addAppoint(appointment);
    }

    public int deleteAppoint(String aid) {
        return bookMapper.deleteAppoint(aid);
    }

    public List<Appointment> queryAllAppoint() {
        return bookMapper.queryAllAppoint();
    }

    public List<Appointment> queryAllAppointBySno(String sno) {
        return bookMapper.queryAllAppointBySno(sno);
    }

    public int changeState(String aid, int state) {
        return bookMapper.changeState(aid,state);
    }

    public Appointment queryAppointByAid(String aid) {
        return bookMapper.queryAppointByAid(aid);
    }
}
